<?php
use services\models\OrderInfo;
USE services\models\Payment;
use common\helper\UrlManager;

$this->context->bodyClass = 'page-pay';

$reduce_amount = explode('.',$order->member_money);
if(count($reduce_amount) ==1){
    $reduce_amount[] = '00';
}else{
    $reduce_amount[1] = substr($reduce_amount[1] .'00', 0,2);
}
?>
    <header>
        <div class="header-left" id="back"><span class="icon icon-arrow-left"></span></div>
        <h1>支付订单</h1>
    </header>
    <section class="pay">
        <div class="pay-info">
            <ul>
                <li class="box">
                    <div class="list-name">付款金额：</div>
                    <div class="list-value flex1">
					<i class="red">￥<?= $order->order_amount ?></i> (已用余额抵扣<i
						class="red">￥<?= $reduce_amount[0] ?>.<?= $reduce_amount[1] ?></i>)
                    </div>
                </li>
                <li class="box">
                    <div class="list-name">试豆金额：</div>
                    <div class="list-value flex1"><i class="red"><?= $order->try_coin ?>试豆</i>(已扣除，订单取消时返回)</div>
                </li>
                <li class="box">
                    <div class="list-name">订单号：</div>
                    <div class="list-value flex1"><?= $order->order_sn ?></div>
                </li>
            </ul>
        </div>
        <div class="pay-method">
            <h2>支付方式</h2>
            <ul id="payMethod">
                <?php if($is_wechat):?>
                <li id="wxpay" type="<?=OrderInfo::$PAY_TYPE_WEIXIN?>"><span class="wxpay-image"></span><span>微信支付</span></li>
                <?php endif;?>
               
                <li id="alipay" type="<?=OrderInfo::$PAY_TYPE_ALIPAY?>"><span class="alipay-image"></span><span>支付宝支付</span></li>
               
            </ul>
        </div>
    </section>
    <div class="bottom-btn" id="payBtn">支付订单</div>
<?php $this->beginBlock('js'); ?>
    <script src="<?= Yii::getAlias('@static') ?>/wap/common/js/zepto.min.js"></script>
    <script src="<?= Yii::getAlias('@static') ?>/wap/common/js/fastclick.min.js"></script>
    <script src="<?= Yii::getAlias('@static') ?>/wap/common/js/king.wap.js"></script>
    <script>
        var wxpayUrl = '<?= UrlManager::createUrl(Yii::$app->params['domains']['api_url'], ['payment/wxpay','order_info_id'=>$order->order_info_id,'hashValue'=>Payment::getPaymentHash($order->order_info_id),'pay_method'=>5]) ?>';
		var alipayUrl = '<?=Yii::$app->urlManager->createUrl(["order/alipay-jump",'order_info_id'=>$order->order_info_id,'pay_method'=>1]);?>';
		var payUrl = {5:wxpayUrl, 1:alipayUrl};
		var orderDetailUrl = '<?=Yii::$app->urlManager->createUrl(["order-details/order-detail"]);?>';
		var orderList = '<?=Yii::$app->urlManager->createUrl(["order-details/order-list"]);?>';
        $(function () {
			$("#back").on("click", function(){$.go(-1)});
            $("#payMethod").on("click", "li", function () {
                $(this).addClass("selected").siblings().removeClass("selected");
            });
			$("#payBtn").on("click", function(){
				var payMethod = $("#payMethod li.selected");
				if(payMethod.size()>0){
					$.go(payUrl[payMethod.attr("type")])
				}else{
					$.tips("请选择一个支付方式")
				}
				_hmt.push(['_trackEvent', '立即支付WAP', 'click', '立即支付WAP']);
			});
        })
    </script>
<?php $this->endBlock(); ?>

<?php $this->beginBlock('css'); ?>
    <link rel="stylesheet" type="text/css" href="<?= Yii::getAlias('@static') ?>/wap/liketry/css/cart.css">
<?php $this->endBlock(); ?>